import React, { Component } from 'react'

export default class EffectClass extends Component {
  constructor() {
    super()
    this.state = {
      count: 0
    }
  }
  componentDidMount() {
    document.title = `点击次数：${this.state.count}`
  }
  componentDidUpdate(){
    document.title = `点击次数：${this.state.count}`
  }
  changeCount() {
    this.setState({
      count: this.state.count + 1
    })
  }
  render() {
    return (
      <div>
        <p>点击按钮，数字增加，页面标题也发生变化</p>
        <button onClick={() => this.changeCount()}>点击次数：{this.state.count}</button>
      </div>
    )
  }
}
